import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "about_orm.settings")
import django

django.setup()

from app01 import models

from django.db.models import F, Q

# ret = models.Book.objects.filter(sale__gt=F('num'))

# ret = models.Book.objects.update(sale=F('sale') * 2 + 10)


# ret = models.Book.objects.filter(pk__gt=2)
# ret = models.Book.objects.filter(pk__lt=5)
# ret = models.Book.objects.filter(pk__lt=5,pk__gt=2)
# ret = models.Book.objects.exclude(pk__lte=5,pk__gte=2)

ret = models.Book.objects.filter(~Q(~Q(pk__gt=5) | Q(pk__lt=2)))

# Q(条件)
# Q(条件)&Q(条件)  与
# Q(条件)|Q(条件)  或
# ~Q(条件)         非

